home *** CD-ROM | disk | FTP | other *** search
- /* Convert photoshop 2.5.x and 3.x clut files to clut resource files
-
- Actual conversion routine "PShopPal v1.0" by Reevan McKay.
- Minimal user interface added by Mark Elliott, 28 Jan 1996.
- Makes no system checks. Currently only works for 256 colour cluts.
- Could be modified to allow combination of colours from more than
- one clut (put up a dialog to get the values of position and
- colorCount). I will probably do this next.
-
- I make no warranty about the suitability of this program for any
- purpose. It shouldn't be able to do any damage since it hardly
- does anything at all, but then again it might. If something
- goes wrong, tell me and I will fix the program, but I won't
- fix your hard disk!!!!!
-
-
-
- */
-
-
-
- #include <pictutils.h>
- #include <memory.h>
-
- extern OSErr LoadPalette (FSSpec theFSpec, CTabHandle theCtab,
- unsigned char position, unsigned char colorCount);
-
-
- void main (void)
- {
- short clutFile;
- FSSpec clutResFile;
- OSErr theError;
- CTabHandle theCtab;
- SFTypeList theTypes;
- StandardFileReply myReply, saveReply;
-
-
- InitGraf( &qd.thePort );
- InitFonts();
- InitWindows();
- FlushEvents( everyEvent, 0 );
- InitCursor();
- InitMenus();
- TEInit();
- InitDialogs( 0L );
-
- theCtab = GetCTable(8); // start with the system 8-bit clut
-
- theTypes[0] = '8BCT'; // photoshop clut file type
-
- StandardGetFile(nil, 1, theTypes, &myReply);
-
- if (myReply.sfGood)
- {
- theError = LoadPalette (myReply.sfFile, theCtab, 0, 255);
-
- // create a resource file for the clut resource
-
- if (theError == 0L)
- {
- StandardPutFile("\pSave clut as...", "\pclut resource", &saveReply);
-
- if (saveReply.sfGood)
- {
- FSpCreateResFile( &saveReply.sfFile, 'RSED', 'rsrc', smCurrentScript);
- FSpOpenResFile( &saveReply.sfFile, fsRdWrPerm );
-
- /* get the file number */
-
- clutFile = CurResFile();
-
-
- /* add the new resource to the file */
-
- AddResource((Handle)theCtab, 'clut', 128, "\p");
- UpdateResFile(CurResFile());
- }
- }
-
- }
- }